<?php
require_once('libs/head.php');
require_once('libs/helper.php');

class Controller{
	public $cfg;
	public $model;
	public $com;
	public $view;
	public $id;
	public $head;
	public function __construct($_cfg,$_com,$_view,$_id){
		$this->cfg = $_cfg;
		$this->com = $_com;
		$this->view = $_view;
		$this->id = $_id;
		$this->head = new LHead();
	}

	public function addcom(){
		if((@include 'components/'.$this->com.'/views/'.$this->view.'/default.php') === false)
		{
			include_once 'templates/404.html';
		}
	}

	public function addmod($name){
		if((@include_once 'modules/mod_'.$name.'/default.php') === false)
		{
			include_once 'templates/404.html';
		}
	}

	public function display(){
		$functionName = $this->view;
		$this->$functionName();
		if((@require_once 'templates/'.$this->cfg->template.'/default.php') === false)
		{
			include_once 'templates/404.html';
		}
	}
}